<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <title>用户登录</title>

    <!-- Bootstrap 5 核心CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap 图标 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
    <!-- jQuery -->
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

    <style>
        :root {
            --primary-gradient: linear-gradient(135deg, #8E2DE2 0%, #4A00E0 100%);
            --hover-gradient: linear-gradient(135deg, #9d4edd 0%, #6a1b9a 100%);
            --text-primary: #2d3436;
            --text-secondary: #636e72;
            --success: #00b894;
            --error: #d63031;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .custom-navbar {
            background: #fff !important;
            box-shadow: 0 2px 4px rgba(127, 9, 156, 0.1);
            backface-visibility: hidden;
            -webkit-backface-visibility: hidden;
        }

        main {
            padding-top: 80px;
            min-height: 100vh;
        }

        .navbar-brand {
            color: var(--main-purple) !important;
            font-weight: 600;
        }

        .nav-link {
            color: #666 !important;
            transition: 0.2s !important;
        }

        .nav-link:hover,
        .nav-link.active {
            color: var(--main-purple) !important;
        }

        .btn-custom {
            background-image: var(--primary-gradient);
            color: white !important;
            transition: var(--transition);
            border: none;
            position: relative;
            overflow: hidden;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .btn-custom:hover {
            background-image: var(--hover-gradient);
            box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
            transform: translateY(-2px);
        }

        .btn-custom::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 300px;
            height: 300px;
            background-color: rgba(255, 255, 255, 0.15);
            border-radius: 50%;
            transform: translate(-50%, -50%) scale(0);
            transition: var(--transition);
        }

        .btn-custom:hover::after {
            transform: translate(-50%, -50%) scale(1);
        }

        .form-control:focus {
            border-color: var(--main-purple);
            box-shadow: 0 0 0 0.25rem rgba(127, 9, 156, 0.25);
        }

        .login-container {
            max-width: 440px;
            margin: 0 auto;
            animation: fadeInUp 0.6s ease;
        }

        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .form-control {
            border-radius: 8px;
            padding: 1rem;
            transition: var(--transition);
        }

        .form-control:focus {
            box-shadow: 0 0 0 3px rgba(142, 45, 226, 0.25);
        }

        .input-group {
            position: relative;
            margin-bottom: 1.5rem;
        }

        .input-error {
            display: none;
            color: var(--error);
            font-size: 0.875rem;
            margin-top: 0.25rem;
        }

        .success-message {
            display: none;
            background: var(--success);
            color: white;
            padding: 1rem;
            border-radius: 8px;
            text-align: center;
            margin-top: 1rem;
            animation: fadeIn 0.3s ease;
        }

        .loader {
            width: 24px;
            height: 24px;
            border: 3px solid #fff;
            border-bottom-color: transparent;
            border-radius: 50%;
            animation: rotation 1s linear infinite;
            display: none;
        }

        @keyframes rotation {
            0% {
                transform: rotate(0deg)
            }

            100% {
                transform: rotate(360deg)
            }
        }

        @media (max-width: 768px) {
            #navbarNav {
                background: var(--light-purple);
                padding: 1rem;
                margin-top: 0.5rem;
                border-radius: 8px;
            }
        }
    </style>
</head>

<body>
    <!-- Header placeholder will be loaded by components.js -->
    <div id="header-container"></div>

    <main class="container">
        <div class="login-container">
            <div class="card shadow-lg">
                <div class="card-body p-4 p-lg-5">
                    <a href="index.html" class="btn btn-link text-decoration-none mb-4">
                        <i class="bi bi-arrow-left"></i>
                    </a>

                    <div class="text-center mb-4">
                        <i class="bi bi-person-circle fs-1" style="color: var(--main-purple);"></i>
                    </div>

                    <h2 class="card-title text-center mb-4">用户登录</h2>

                    <form id="loginForm" novalidate>
                        <div class="input-group">
                            <div class="form-floating">
                                <input type="text" class="form-control form-control-lg" id="username" placeholder="用户名"
                                    pattern="[a-zA-Z0-9]{3,16}" required>
                                <label for="username"><i class="bi bi-person-fill me-2"></i>用户名</label>
                            </div>
                            <div class="input-error" data-error="username">用户名需3-16位字母或数字</div>
                        </div>

                        <div class="input-group">
                            <div class="form-floating position-relative">
                                <input type="password" class="form-control form-control-lg pe-5" id="password"
                                    placeholder="密码" minlength="6" required>
                                <label for="password"><i class="bi bi-lock-fill me-2"></i>密码</label>
                                <button type="button"
                                    class="btn btn-link position-absolute end-0 top-50 translate-middle-y me-2"
                                    id="togglePassword">
                                    <i class="bi bi-eye-slash"></i>
                                </button>
                            </div>
                            <div class="input-error" data-error="password">密码至少6位字符</div>
                        </div>

                        <button type="submit" class="btn btn-lg btn-custom w-100 mt-4">
                            <span class="submit-text">立即登录</span>
                            <div class="loader"></div>
                        </button>

                        <div class="success-message mt-3">登录成功！正在跳转...</div>

                        <div class="d-flex justify-content-between mt-4">
                            <a href="#" class="text-decoration-none text-secondary">忘记密码？</a>
                            <a href="reg.html" class="text-decoration-none text-secondary">注册账号</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </main>

    <!-- Footer placeholder will be loaded by components.js -->
    <div id="footer-container"></div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="../js/components.js"></script>
    <script src="../js/login.js"></script>
</body>

</html>